<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // var performanceS = function () { }
        // performanceS.prototype.calculate = function (salary) {
        //     return salary * 4
        // }
        // var performanceA = function () { }

        // performanceA.prototype.calculate = function (salary) {
        //     return salary * 3
        // }

        // var performanceB = function (salary) { }
        // performanceB.prototype.calculate = function (salary) {
        //     return salary * 2
        // }

        var strategies = {
            S: function (salary) {
                return salary * 4
            },
            A: function (salary) {
                return salary * 3
            },
            B: function (salary) {
                return salary * 2
            },
        }

        var calculateBouns = function (performanceLevel, salary) {
            return strategies[performanceLevel](salary)
        }

        console.log(calculateBouns("A", 20000))
        // var Bonus = function () {
        //     this.salary = null
        //     this.strategy = null
        // }
        // Bonus.prototype.setSalary = function (salary) {
        //     this.salary = salary
        // }
        // Bonus.prototype.setStrategy = function (strategy) {
        //     this.strategy = strategy
        // }

        // Bonus.prototype.getBouns = function (salary) {
        //     return this.strategy.calculate(this.salary)
        // }

        // var bouns1 = new Bonus()
        // bouns1.setSalary(10000)
        // bouns1.setStrategy(new performanceS())
        // console.log(bouns1.getBouns())
        // var bouns2 = new Bonus()
        // bouns2.setSalary(20000)
        // bouns2.setStrategy(new performanceB())
        // console.log(bouns2.getBouns())

    </script>
</body>

</html>